<template>
	<view>
		<u-sticky  bgColor="#fff">
			<u-tabs :list="list1" lineWidth="15" :scrollable="false" :activeStyle="{
		        color: '#3478f5',
		        fontWeight: 'bold',
		        transform: 'scale(1.05)'
		    }" @change="tabclick"></u-tabs>
		</u-sticky>
		<view class="mainpadding2">
			<!-- 优课 -->
			<template v-if="tabsId==1">
				<view class="flexbetween flex_wrap">
					<view class="itemgoods ffffff radius margin_top" v-for="item in list.data" :key="item.id" @click="jumpurl('/pages_index/youkexq?id=',item.lesson.id)">
						<image :src="item.lesson.image_text" class="goodstopimg" mode=""></image>
						<view class="" style="padding: 30rpx 15rpx;">
							<view class="main_size hei_text bold xiankuan">{{item.lesson.name}}</view>
							<view class="flexbetween margin_top2">
								<view class="viplable" v-show="item.lesson.is_vip">vip</view>
								<view class="bianhao">编号：{{item.lesson.id}}</view>
							</view>
							<view class="flexbetween margin_top2">
								<view class="flexleft">
									<image :src="item.lesson.myteacher.avatar" mode="" class="listheadimg"></image>
									<view class="xiaohei xiankuan margin_left1" style="width: 80rpx;">{{item.lesson.myteacher.username}}</view>
								</view>
								<view class="xiaohong">￥{{item.lesson.price}}</view>
							</view>
						</view>
					</view>
				</view>
			</template>
			<!-- 辅导 -->
			<template v-if="tabsId==2">
				<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id" @click="jumpurl('/pages_index/fudaoxq?id=',item.lesson.id)">
					<view class="yihang hei_text bold main_size">{{item.lesson.name}}</view>
					<view class="flexleft margin_top2">
						<view class="viplable margin_right" v-show="item.lesson.is_vip">vip</view>
						<view class="bianhao">编号：{{item.lesson.id}}</view>
					</view>
					<view class="flexbetween margin_top2">
						<view class="flexleft">
							<image :src="item.lesson.myteacher.avatar" mode="" class="listheadimg"></image>
							<view class="xiaohei margin_left1">{{item.lesson.myteacher.username}}</view>
						</view>
						<view class="xiaohong">￥{{item.lesson.price}}</view>
					</view>
				</view>
			</template>
			<!-- 测试 -->
			<template v-if="tabsId==3">
				<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id"  @click="jumpurl('/pages_index/ceshixq?id=',item.lesson.id)">
					<view class="yihang hei_text bold main_size">{{item.lesson.name}}</view>
					<view class="flexbetween margin_top2">
						<view class="flexleft ">
							<view class="viplable margin_right" v-show="item.lesson.is_vip">vip</view>
							<view class="bianhao">编号：{{item.lesson.id}}</view>
						</view>
						<view class="xiaohong">￥{{item.lesson.price}}</view>
					</view>
					<view class="flexbetween margin_top2">
						<view class="flexleft">
							<image :src="item.lesson.myteacher.avatar" mode="" class="listheadimg"></image>
							<view class="xiaohei margin_left1">{{item.lesson.myteacher.username}}</view>
						</view>
						<view class="listbtnlan" v-if="!item.lesson.is_free" @click.stop="kecheng_pay(item.id)">立即购买</view>
						<view class="listbtnlan" v-if="item.lesson.is_free" @click="jumpurl('/pages_mine/ceshitjq?id=',item.lesson.id)">立即考试</view>
					</view>
				</view>
			</template>
			<!-- 资料 -->
			<template v-if="tabsId==4">
				<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id" @click="jumpurl('/pages_index/ziliaoxq?id=',item.lesson.id)">
					<view class="yihang hei_text bold main_size">{{item.lesson.name}}</view>
					<view class="flexleft margin_top2">
						<view class="viplable margin_right" v-show="item.lesson.is_vip">vip</view>
						<view class="bianhao">编号：{{item.lesson.id}}</view>
					</view>
					<view class="flexbetween margin_top2">
						<view class="flexleft">
							<image :src="item.lesson.myteacher.avatar" mode="" class="listheadimg"></image>
							<view class="xiaohei margin_left1">{{item.lesson.myteacher.username}}</view>
						</view>
						<view class="xiaohong">￥{{item.lesson.price}}</view>
					</view>
				</view>
			</template>
			<!-- 老师 -->
			<template v-if="tabsId==5">
				<view class="mainpadding_top ffffff flexleft radius" v-for="item in list.data" :key="item.id"
					@click="jumpurl('/pages_index/personalHomepage?id=',item.teacher.id)">
					<view class="headimg" style="position: relative;">
						<image :src="item.teacher.avatar" class="headimg" mode=""></image>
						<view class="zaixian" v-if="item.teacher.status=='normal'"></view>
						<view class="lixian" v-else></view>
					</view>
					<view class="flexcolumnbet margin_left2" style="height: 120rpx;width: 100%;">
						<view class="flexbetween" style="width: 100%;">
							<view class="hei_text main_size bold">{{item.teacher.username}}</view>
							<view class="xiaohong">￥{{item.teacher.price}}/一次</view>
						</view>
						<view class="flexbetween" style="width: 100%;">
							<view class="xiaohui lianghang">{{item.teacher.description}}</view>
							<view class="tiwen xiaobai" @click.stop="jumpurl('/pages_askquestion/lijitw?id=',item.teacher.id)">
								立即提问</view>
						</view>
					</view>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list1: [{
						name: "优课",
						id: 1,
					},
					{
						name: "辅导",
						id: 2,
					},
					{
						name: "测试",
						id: 3,
					},
					{
						name: "资料",
						id: 4,
					},
					{
						name: "老师",
						id: 5,
					}
				],
				tabsId: "1",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/member/mycollects', 'GET', {
					page: page || 1,
					type:this.tabsId
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			tabclick(item) {
				this.tabsId = item.id
				this.init()
			},
			jumpurl(url,id){
				uni.navigateTo({
					url:url+id
				})
			},
		}
	}
</script>

<style>

</style>